package cn.jzq.kotoba.modules.designpattern.factory.shape;

/**
 * 使用静态方法
 * 缺点: 1. 不能通过继承来改变创建的行为
 * 2. 违背开闭原则
 *
 * @author jzq
 * @date 2019/2/19 11:02
 */
public class SimpleShapeFactory {

    public static Shape createShape(ShapeEnum shapeEnum) {
        switch (shapeEnum) {
            case RectangleType:
                return new Rectangle();
            case CircleType:
                return new Circle();
            case SquareType:
                return new Square();
            default:
        }
        return new Rectangle();
    }
}
